<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>客户列表</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
	<link id="bootstrap-style" href="<c:url value="/css/bootstrap.min.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/bootstrap-responsive.min.css"/>" rel="stylesheet">
	<link id="base-style" href="<c:url value="/css/style.css"/>" rel="stylesheet">
	<link id="base-style-responsive" href="<c:url value="/css/style-responsive.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/index.css"/>" rel="stylesheet">
	<link rel="shortcut icon" href="<c:url value="/img/favicon.ico"/>">
	<link href="<c:url value="/css/page.css"/>" rel="stylesheet">
	<%-- <link rel="stylesheet" type="text/css" href="<c:url value="/css/jquery.datetimepicker.css"/>"/> --%>
	<link href="<c:url value="/css/navuser.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/but.css"/>" rel="stylesheet">
	<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
	<script src="<c:url value="/js/jquery-migrate-1.0.0.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/layer/layer.js"/>"></script>
	<script src="<c:url value="/js/laydate/laydate.js"/>"></script>
	<%-- <script src="<c:url value="/js/build/jquery.datetimepicker.full.js"/>"></script> --%>
	<script src="<c:url value="/js/orgin.js"/>"></script>
	<script src="<c:url value="/js/filebut.js"/>"></script>
	
</head>
 <script type="text/javascript">
 $(function(){
	 if("${Code}"){ 
	 }else{
		 $("#select1").hide();
	 }
 })
 function gotoPage(pageNum){
	 	var totalPage=jQuery("#totalPage").val();
		regexpdat=/^\d+$/;
		if(!regexpdat.test(pageNum)){
			alert("查询的页面必须为数字");
			return ;
		}
		if(1 > Number(pageNum) || Number(pageNum) > totalPage){
			alert("请求页面不在范围之内，请重新输入");
			return;
		}
		jQuery("#currentPage").val(pageNum);
		document.forms["frm"].submit();
	}
 
 function submitForm(){
	 var custname=jQuery("#custname").val();
	 custname= encodeURI(encodeURI(custname));
	 jQuery("#name").val(custname);
	 document.forms["frm"].submit();
 }
 function xiugai(id) {
	 layer.open({
			title: '修改客户',
	       type: 2,
	       area: ['550px', '586px'],
	       fixed: false, //不固定
	       maxmin: false,
	       content: '<%=basePath%>crm/addCustomerMain?id='+id
	     });
 }
 function selectlook(id) {
	 layer.open({
			title: '查看客户',
	       type: 2,
	       area: ['750px', '516px'],
	       fixed: false, //不固定
	       maxmin: false,
	       content: '<%=basePath%>crm/look?id='+id
	     });
 }
 function deleteUser(id){
	 if(confirm("确定删除该客户信息吗?")){
			jQuery.ajax({
				url:'<%=basePath%>user/deleteUser?id='+id,
				type:"post",
				dataType:"json",
				success:function(json){
				}
			});
			window.location.reload();
		}
 }
 function xinzeng1() {
     layer.open({
		title: '新增客户',
       type: 2,
       area: ['550px', '586px'],
       fixed: false, //不固定
       maxmin: false,
       content: '<%=basePath%>crm/addCustomerMain'
     });
 }
 function daochu(){
	 if("${Code}"){
		 var url=$("#basePath").attr("value");
		 url+="crm/export";
		 $("#frm").attr('action',url);
		 document.forms["frm"].submit();
	 }
 }
 function followUp(custId) {
     layer.open({
		title: '跟进记录',
       type: 2,
       area: ['750px', '516px'],
       fixed: false, //不固定
       maxmin: false,
       content: '<%=basePath%>crm/followUpByCustomer?custId='+custId
     });
 }
 function linkman(id,status){
	 var url=$("#basePath").attr("value");
	 url +="crm/linkmanlist?id="+id+"&status="+status;
	 parent.$("#mainFrame").attr("src",url);
 }
 function bracket(id){
	 if(confirm("确定对该客户封档吗?")){
		 $.ajax({  
	         url: '<%=basePath%>crm/bracket?id='+id,
	         type: 'POST',  
	         async: false,  
	         cache: false,
	         contentType: false,  
	         processData: false,  
	         success: function (result) {
	               if("ok"==result){
	                   alert("封档成功");
	                   window.location.reload(); //刷新页面
	               }else if("no"==result){
	                   alert("封档失败");
	               }
	         }
	    });
	 }
 }
 function deArchive(id){
	 if(confirm("确定对该客户解封吗?")){
		 $.ajax({  
	         url: '<%=basePath%>crm/deArchive?id='+id,
	         type: 'POST',  
	         async: false,  
	         cache: false,
	         contentType: false,  
	         processData: false,  
	         success: function (result) {
	               if("ok"==result){
	                   alert("解封成功");
	                   window.location.reload(); //刷新页面
	               }else if("no"==result){
	                   alert("解封失败");
	               }
	         }
	    });
	 }
 }
 function updateType(id,type){
	 var typeStr = "";
	 if(type == 1){
		 typeStr = "潜在";
	 }else if(type == 2){
		 typeStr = "意向";
	 }else if(type == 3){
		 typeStr = "签约";
	 }
	 if(confirm("确定把该客户定为"+typeStr+"客户吗?")){
		 $.ajax({  
	         url: '<%=basePath%>crm/updateType?id='+id+'&type='+type,
	         type: 'POST',  
	         async: false,  
	         cache: false,
	         contentType: false,  
	         processData: false,  
	         success: function (result) {
	               if("ok"==result){
	                   alert("定义成功");
	                   window.location.reload(); //刷新页面
	               }else if("no"==result){
	                   alert("定义失败");
	               }
	         }
	    });
	 }
 }
 </script>
<body>
<div class="container-fluid-full">
	<div class="row-fluid">
		<div id="basePath" value="<%=basePath%>" style="display:block;"></div>
		<form name="frm" id="frm" method="get" action="<%=basePath%>crm/index">
				<input type="hidden" id="totalPage" name="totalPage" value="${totalPage}"> 
				<input type="hidden" id="currentPage" name="currentPage" value="${currentPage}"> 
				<input type="hidden" id="name" name="name" value="${name}"> 
				<div id="content" class="span10" >
					<div class="row-fluid content-search">
						<div>
							<span>搜索</span>
							<input type="text" id="custname" name="custname" value="${name}" style="width: 200px">
							<span>客户类型</span>
							<select id="type" name="type" class="buildselect">
								<option value="">请选择</option>
								<option value="1" ${1==type?'selected':''}>潜在客户</option>
								<option value="2" ${2==type?'selected':''}>意向客户</option>
								<option value="3" ${3==type?'selected':''}>签约客户</option>
							</select>
						</div>
						<div><button class="but" type="button" id="select" onclick="submitForm();">查询</button></div>
						<div><button class="but" type="button" id="select" onclick="xinzeng1();">添加客户</button></div>
						<div><button class="but" type="button" id="select1" onclick="daochu();">导出</button></div>
					</div>
					<div class="row-fluid content-table">
						<table class="table table-striped table-bordered bootstrap-datatable">
						  <thead>
							  <tr>
							  	  <th>公司名</th>
							  	  <th>地址</th>
								  <th>邮政编码</th>
								  <th>电话</th>
								  <th>网址</th>
								  <th>所属行业</th>
								  <th>推荐人</th>
								  <th>备注</th>
								  <th>状态</th>
								  <th>联系人</th>
								  <th>客户类型</th>
								  <th>操作</th>
							  </tr>
						  </thead>   
						  <tbody>
						  	<c:forEach items="${list }" var="a">
								<tr>
									<td>${a.custName }</td>
									<td>${a.custAddress }</td>
									<td>${a.custZip }</td>
									<td>${a.custTel }</td>
									<td>${a.custWebsite }</td>
									<td>${a.industry }</td>
									<td>${a.introducer }</td>
									<td class="longField" title="${a.memo }">${a.memo }</td>
									<c:if test="${a.status == 1 }">
										<td>跟进中</td>
									</c:if>
									<c:if test="${a.status == 2 }">
										<td>未跟进</td>
									</c:if>
									<c:if test="${a.status == 3 }">
										<td style="color: red;">已封档</td>
									</c:if>
									<td>
										<a style="color: #3300ff;" href="#" onclick="linkman(${a.id},${a.status })">查看列表</a>
									</td>
									<td>
										<c:if test="${a.type == 1 }">
											<span style="color: #37c2c2;">潜在客户</span>
											<a style="color: black;" href="#" onclick="updateType(${a.id},2);">意向</a>
											<a style="color: black;" href="#" onclick="updateType(${a.id},3);">签约</a>
										</c:if>
										<c:if test="${a.type == 2 }">
											<a style="color: black;" href="#" onclick="updateType(${a.id},1);">潜在</a>
											<span style="color: #37c2c2;">意向客户</span>
											<a style="color: black;" href="#" onclick="updateType(${a.id},3);">签约</a>
										</c:if>
										<c:if test="${a.type == 3 }">
											<a style="color: black;" href="#" onclick="updateType(${a.id},1);">潜在</a>
											<a style="color: black;" href="#" onclick="updateType(${a.id},2);">意向</a>
											<span style="color: #37c2c2;">签约客户</span>
										</c:if>
									</td>
									<td>
										<a href="#" onclick="selectlook(${a.id});">查看</a>
										<c:if test="${a.status == 3 }">
											<a href="#" onclick="deArchive(${a.id});">解封</a>
										</c:if>
										<c:if test="${a.status != 3 }">
											<a href="#" onclick="xiugai(${a.id});">修改</a>
											<a href="#" onclick="bracket(${a.id});">封档</a>
											<a href="#" onclick="followUp(${a.id})">跟进</a>
										</c:if>
									</td>
								</tr>
						  	</c:forEach>
						  </tbody>
					  </table>            
					</div>
					
					<div id="app">
				    <div>
				      <div class="page"  v-show="show">
				      	<div class="span">
						</div>
				        <div class="pagelist">
				          <span class="jump" :class="{disabled:pstart}" onClick="gotoPage(1);">首页</span>
				          <span class="jump" :class="{disabled:pstart}" onClick="gotoPage(${currentPage}-1);return false;">上一页</span>
				          <span v-show="current_page>5" class="jump" onClick="gotoPage(1);">1</span>
				          <span class="ellipsis"  v-show="efont">...</span>
				          <span class="jump" v-for="num in indexs" :class="{bgprimary:current_page==num}" onClick="gotoPage(jQuery(this).text());">{{num}}</span>
				          <span class="ellipsis"  v-show="ebehind">...</span>
				          <span :class="{disabled:pend}" class="jump" onClick="gotoPage(${currentPage}+1);return false;">下一页</span>
				          <span v-show="current_page<pages-4" class="jump" onClick="gotoPage(${totalPage})">{{pages}}</span>
				          <span class="jumppoint">跳转到：</span>
				          <span class="jumpinp"><input type="text" v-model="changePage" name="pageNum" id="pageNum" value=""/></span>
				          <span class="jump gobtn" onClick="gotoPage(jQuery('#pageNum').val())">GO</span>
				        </div>
				      </div>
				    </div>
				  </div>
				</div>
		</form>
	</div>
</div>
			<script src="<c:url value="/js/vue.js"/>"></script>
			<script src="<c:url value="/js/vueClick.js"/>"></script>
</body>
</html>
